
$(function () {
    $("#startRevisitTime").val(setDateTime(new Date(), 0) + " " + "00:00:00");
    $("#endRevisitTime").val(setDateTime(new Date(), 0) + " " + "23:59:59");
    $(".patient-content-switch > div").eq(0).click();
    TcRevisitStatus();
});

$(".patient-content-switch > div").click(function () {
    $(this).addClass('selection').siblings().removeClass('selection')
});

function setTcRevisitStatus(revisitStatus) {  //点击回访状态
    document.getElementById("revisitStatus").value=revisitStatus;
    TcRevisitStatus();
};

function TcRevisitStatus() {
    var startRevisitTime =  $("#startRevisitTime").val();
    var endRevisitTime =  $("#endRevisitTime").val();
    var revisitStatus = $("#revisitStatus").val();
    var revisit = $("#revisit").val();
    var followStatus = $("#followStatus").val();
    var consumptionStatus = $("#consumptionStatus").val();
    $.ajax({
        url: Feng.ctxPath + "/tcPatientsCentral/tc_returnVisit_list",
        type: "POST",
        data: {
            revisitStatus: revisitStatus,
            startRevisitTime: startRevisitTime,
            endRevisitTime: endRevisitTime,
            revisit: revisit,
            followStatus: followStatus,
            consumptionStatus: consumptionStatus
        },
        success: function (data) {
            var text = '';
            for (var i = 0; i < data.length; i++) {
                text += ' <div class="patient-box-item" > ' +
                    '<div class="patient-box-item-top" onclick="tc_patient_returnVisit('+"'"+ data[i].reservationsId +"'"+')"> ';
                if(data[i].customerSex==1){
                    text+= '<div class="patient-item-portrait"><img src="https://pynnn.oss-cn-hangzhou.aliyuncs.com/weixin-img/app/portrait01.png" alt="加载中..."></div>' ;
                }else if(data[i].customerSex==2){
                    text+= '<div class="patient-item-portrait"><img src="https://pynnn.oss-cn-hangzhou.aliyuncs.com/weixin-img/app/portrait02.png" alt="加载中..."></div>' ;
                }else {
                    text+= '<div class="patient-item-portrait"><img src="https://pynnn.oss-cn-hangzhou.aliyuncs.com/weixin-img/app/portrait03.png" alt="加载中..."></div>' ;
                }
                text+= '<div class="patient-item-information"> ' +
                    '   <div class="patient-item-information-show"> ' +
                    '     <div><span>' + data[i].customerName + '</span><span>' + data[i].customerAge + '岁 </span></div> ' +
                    '     <div>' + data[i].customerPhone + '</div> ' +
                    '   </div> ' +
                    '   <div class="patient-item-information-operation"> ' +
                    '      <button onclick="tc_patient_editVisit('+"'"+ data[i].reservationsId +"','"+ data[i].id +"'"+')"><i class="layui-icon layui-icon-rate-solid"></i></button> ' +
                    '   </div> ' +
                    '  </div> ' +
                    ' </div> ' +
                    '</div>';
            }
            $("#tcReturnVisitList").html(text);
        },
        error: function (data) {

        }
    });
}

//tc回访记录
function tc_patient_returnVisit(reservationsId) {
    window.location.href = Feng.ctxPath + "/tcPatientsCentral/tcPatient_returnVisit/"+reservationsId;
}

//tc回访 编辑
function tc_patient_editVisit(reservationsId,id) {
    var e = window.event || arguments.callee.caller.arguments[0];
    e.stopPropagation()
    window.location.href = Feng.ctxPath + "/tcPatientsCentral/tc_patient_editVisit/"+reservationsId+"/"+id;
}


function deployment_conditions(obj) {
    $(obj).hide().siblings().show();
    $(".patient-box-election").show().siblings().hide();
}

function tcdeployment_complete(obj) {
    TcRevisitStatus();
    $(obj).hide().siblings().show();
    $(".patient-box-content").show().siblings().hide();
}

function patient_backHome() {  ////点击返回跳转页面 - 首页
    window.location.href = Feng.ctxPath + "/weixin/index";
}